﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using CID.Domain.Operations;
using CID.Domain.Users;
using CID.Web.Support;
using NailsFramework.IoC;
using NailsFramework.Persistence;
using NailsFramework.UserInterface;

namespace CID.Web.Controllers
{
    [CIDAuthorize(UserRole.Architect, UserRole.Manager, UserRole.Operator, UserRole.ReleaseManager)]
    public class EnvironmentStateController : NailsController
    {
        [Inject]
        public IBag<Environment> Environments { private get; set; }
        public IEnumerable<Environment> EnabledEnvironments { get { return Environments.Where(x => x.Enabled); } }

        public ViewResult Index()
        {
            return View(EnabledEnvironments);
        }

        public ViewResult EnvironmentStateDetails(int id)
        {
            return View(Environments.GetById(id));
        }
    }
}